#include<iostream>
#include<string>
using namespace std;
string Habb[19]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"},
       Tzo[20]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int getorder(string);
int main()
{
    string str;
    int a,t,i,year,td,order,mo;
    char ch;
    cin>>t;
    cout<<t<<endl;
    for(i=0;i<t;i++)
     {
       cin>>a;
       cin>>ch;
       cin>>str;
       cin>>year;
       order=getorder(str);
       td=year*365+a+1+order*20;
       year=td/260;
       td=td%260;
       if (td==0)
        {
         td=260;
         year--;
        }
       mo=td%20;
       if (mo==0)
        mo=20;
       a=td%13;
       if (a==0)
        a=13;
      cout<<a<<' '<<Tzo[mo-1]<<' '<<year<<endl;
     }
    return 0;
}
int getorder(string s)
{
    int i;
    for(i=0;i<19;i++)
     {
       if ((s[0]==Habb[i][0])&&(s[1]==Habb[i][1]))
        return i;
     }
}